package com.zh.test.Thread;

import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 * @Author zh
 * @Description  测试springboot线程池使用
 * @Date 2020/5/29 
 * @Param 
 * @return 
 **/
@Component
public class ThreadPool {
    /**
      https://blog.csdn.net/mj86534210/article/details/79910909?
      utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase&depth_1-utm_source=distribute.pc_relevant.
      none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase

     * */
//    @Autowired
//    private ThreadPoolTaskExecutor thexecutor;
//    public void test(){
//        //每个线程读取自己对应的文件复制到另一个
//        thexecutor.execute(()->{
//            InputStream inp = null;
//            try {
//                inp = new FileInputStream("F:\\wenxin\\WeChat Files\\EmaryZH\\FileStorage\\File\\2020-05\\test.xlsx");
//                Workbook wb = WorkbookFactory.create(inp);
//                Sheet sheet0 = wb.getSheetAt(0);
//                sheet0.getRow(2);
//            } catch (FileNotFoundException e) {
//                e.printStackTrace();
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//
//        });
//
//
//    }

    @Async("custTaskExecutor")
    public void test1(){
        System.out.println(Thread.currentThread().getName());
    }
    @Async("custTaskExecutor")
    public void test2(){
        System.out.println(Thread.currentThread().getName());
    }

    public void test3(){
        System.out.println(Thread.currentThread().getName());
    }
    public static void main(String[] args) {
        int a =1001;
        int b = 100;
        int c = a/2;
        System.out.println(c);
    }
}
